[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 strstr()                Find Substring

 #include   <string.h>                   Required for declarations only

 char       *strstr(string1,string2);
 const char *string1;                    String to search
 const char *string2;                    Substring to search for


    strstr() returns a pointer to the first occurrence of 'string2' in
    'string1'.

       Returns:     A pointer to the first occurrence of 'string2' in
                    'string1'. NULL is returned if 'string2' is not
                    found.

   -------------------------------- Example ---------------------------------

    The following statements search for 'str2' in 'str1'.

           #include <string.h>
           #include <stdio.h>

           char *str1 = "An ounce of prevention";
           char *str2 = "ounce";
           char *substr;

           main()
           {
               substr = strstr(str1,str2);
               if (substr != NULL)
                   printf("%s",substr);
           }


See Also: strspn() strcspn()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson